
module.exports = app => {
    const { STRING, INTEGER, JSON } = app.Sequelize;
    
    const TopicLessonVideo = app.model.define('topic-lesson-video', {
        topicId: {
            type: INTEGER,
            allowNull: false,
        },
        lessonId: {
            type: INTEGER,
            allowNull: false,
        },
        title: {
            type: STRING(255),
            allowNull: false,
        },
        desc: {
            type: STRING(255),
            allowNull: true,
        },

        infos: {
            // 包含poster, duration, size, width, height
            type : JSON,
            allowNull: true,

        },
        type: { 
            type: INTEGER, // 0免费 1 收费
            defaultValue: 0,
        },
        originalVideoLink: {
            type: STRING(255),
            allowNull: false,
        },
        streamingVideoLink: {
            type: STRING(255),
            allowNull: true,
        },
        // 新增的转码状态字段
        transcodingStatus: {
            type: INTEGER,
            allowNull: true,
            defaultValue: 0,
        }
    }, {
        timestamps: true,
        underscored: false,
    });

    return TopicLessonVideo;
};

